package com.jin10.constant;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author raofy
 * @date 2022-02-09 16:55
 * @desc
 */
@Component
public class TitleHandlerClassMap {

    private Logger logger = LoggerFactory.getLogger(getClass());

    private static TitleHandlerClassMap instance = new TitleHandlerClassMap();

    private boolean isOK;

    private TitleHandlerClassMap() {

    }

    public static TitleHandlerClassMap getInstance() {
        return instance;
    }


    private static Map<Integer, Object> beanTable = new ConcurrentHashMap<>();


    public void setBeanTable(Map<Integer, Object> map) {
        if (map != null && map.size() > 0) {
            for (Map.Entry<Integer, Object> entry : map.entrySet()) {
                beanTable.put(entry.getKey(), entry.getValue());
            }
        }
    }

    public Object getTitleHandler(Integer key) {
        if (beanTable.containsKey(key)) {
            return beanTable.get(key);
        } else {
            return null;
        }
    }
}
